コンテナからの Docker イメージ作成
1. コンテナをシェルで実行する
code:shell
$ docker run -i -t centos /bin/bash
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
aeb7866da422: Pull complete
Digest: sha256:67dad89757a55bfdfabec8abd0e22f8c7c12a1856514726470228063ed86593b
Status: Downloaded newer image for centos:latest
2. コンテナ内でアプリケーションインストール
yum update
code:shell
Apache HTTP Server install
code:shell
抜ける
コンテナ確認
code:shell
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5aeee6cee1b1 centos "/bin/bash" 8 minutes ago Exited (0) 3 seconds ago priceless_villani
3. コンテナから Docker イメージを作成する
作成
code:shell
$ docker commit 5aeee6cee1b1 centos-apache-http
sha256:c93287a7ebdf46eacd0035c23b5056450f34be3a7e12964597eb6b74dec4b798
Docker イメージ確認
code:shell
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos-apache-http latest c93287a7ebdf 47 seconds ago 334MB
(snip)
動作確認
code:shell
$ docker run centos-apache-http httpd -V
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Server version: Apache/2.4.6 (CentOS)
Server built: Jun 27 2018 13:48:59
Server's Module Magic Number: 20120211:24
Server loaded: APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"